package com.zhu.websocketdemo.service.impl;

import com.zhu.websocketdemo.pojo.GroupMessage;
import com.zhu.websocketdemo.repository.GroupMessageRepository;
import com.zhu.websocketdemo.service.IGroupMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GroupMessageImpl implements IGroupMessage {
    @Autowired
    private GroupMessageRepository groupMessageRepository;

    @Override
    public GroupMessage save(GroupMessage groupMessage) {
        GroupMessage save = groupMessageRepository.save(groupMessage);
        if (save != null) {
            return save;
        }
        throw new RuntimeException("信息保存失败");
    }

    @Override
    public Iterable<GroupMessage> findAll() {
       return groupMessageRepository.findAll();
    }
}
